﻿using RpcClient.Attr;
using RpcClient.Interface;

namespace RpcSync.DAL
{
    internal class SqlSugarUnity : SqlSugarHelper.IUnityContainer
    {
        private IUnityCollect _Unity;
        public SqlSugarUnity(IUnityCollect unity)
        {
            _Unity = unity;
        }
        public void Register(Type form, Type to)
        {
            _Unity.RegisterType(form, to);
        }

        public void Register<Form, To>()
        {
            _Unity.RegisterType<Form, To>();
        }

        public void RegisterSingle<T>(T to)
        {
            _Unity.RegisterInstance<T>(to);
        }

        public void RegisterSingle<Form, To>()
        {
            _Unity.RegisterType<Form, To>(ClassLifetimeType.单例);
        }

        public T Resolve<T>()
        {
            return _Unity.Resolve<T>();
        }
    }
}
